<template>
  <a-card :bordered="false">
    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline" >
        <a-row :gutter="24">
          <a-col :md="6" :sm="8">
            <a-form-item label="机构">
              <j-dict-select-tag  placeholder="" dictCode="sys_depart,depart_name,id,org_type = '1' " v-model="queryParam.office"/>

              <!--              <j-select-depart v-model="queryParam.office"/>-->
            </a-form-item>
          </a-col>
          <a-col :md="6" :sm="8">
            <a-form-item
              label="年度">
<!--              <vue-datepicker-local v-if="this.reportType==3" style="width: 246px"  ref="time" v-model="date" format="YYYY"></vue-datepicker-local>-->

              <a-select v-model="queryParam.years" @change="dateChange(queryParam.years)">
                <a-select-option v-for="item in year"
                                 :label="item.label"
                                 :value="item.value">{{item.label}}
                </a-select-option>
              </a-select>
            </a-form-item>
          </a-col>
          <a-col :md="6" :sm="8">
            <a-form-item
              label="报告类型">
                <j-dict-select-tag  placeholder="" dictCode="report_type" v-model="queryParam.type"/>
                <!--                  <j-dict-select-tag :triggerChange="true" placeholder="请选择服务器名称" dictCode="dataBaseName"  v-decorator="[ 'dataBaseName', {}]"/>-->
            </a-form-item>
          </a-col>
        </a-row>
        <a-row :gutter="24">
          <a-col :md="12" :sm="8">
            <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
              <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
              <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
              <a-button type="primary" icon="upload" @click="handleAdd" style="margin-left: 8px">上传报告</a-button>
            </span>
          </a-col>
        </a-row>
      </a-form>
    </div>
    <div>
      <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">
        <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择 <a style="font-weight: 600">{{ selectedRowKeys.length }}</a>项
        <a style="margin-left: 24px" @click="onClearSelected">清空</a>
      </div>
      <div v-if="this.type=='0'">
        <a-table
        ref="table"
        size="middle"
        bordered
        rowKey="id"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
        @change="handleTableChange">
        <span slot="action" slot-scope="text, record">
<!--          <a @click="handleDetail(record)">详情</a>|-->
          <a @click="uploadFile(record.filePath)">报告下载</a>
        </span>
      </a-table>
      </div>
      <div v-if="this.type=='1'">
        <a-table
          ref="table"
          size="middle"
          bordered
          rowKey="id"
          :columns="columns1"
          :dataSource="dataSource"
          :pagination="ipagination"
          :loading="loading"
          :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
          @change="handleTableChange">
        <span slot="action" slot-scope="text, record">
<!--          <a @click="handleDetail(record)">详情</a>-->
         <a @click="uploadFile(record.filePath)">报告下载</a>

        </span>
        </a-table>
      </div>
      <div v-if="this.type=='2'">
        <a-table
          ref="table"
          size="middle"
          bordered
          rowKey="id"
          :columns="columns2"
          :dataSource="dataSource"
          :pagination="ipagination"
          :loading="loading"
          :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
          @change="handleTableChange">
        <span slot="action" slot-scope="text, record">
<!--          <a @click="handleDetail(record)">详情</a>-->
              <a @click="uploadFile(record.filePath)">报告下载</a>
        </span>
        </a-table>
      </div>
      <div v-if="this.type=='3'">
        <a-table
          ref="table"
          size="middle"
          bordered
          rowKey="id"
          :columns="columns3"
          :dataSource="dataSource"
          :pagination="ipagination"
          :loading="loading"
          :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
          @change="handleTableChange">
        <span slot="action" slot-scope="text, record">
<!--          <a @click="handleDetail(record)">详情</a>-->
          <a @click="uploadFile(record.filePath)">报告下载</a>
        </span>
        </a-table>
      </div>
    </div>
    <report-model ref="modalForm" @ok="modalFormOk"></report-model>
  </a-card>
</template>

<script>
  import reportModel from './modules/reportModel'
  import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  import JDate from '@/components/jeecg/JDate.vue'
  import JSelectDepart from '@/components/jeecgbiz/JSelectDepart'
  import JUpload from '@/components/jeecg/JUpload'
  import VueDatepickerLocal from 'vue-datepicker-local'

  export default {
    name: "reportManagementList",
    mixins:[JeecgListMixin],
    components: {
      JDate,
      reportModel,
      VueDatepickerLocal,
      JUpload,
      JSelectDepart
    },
    data () {
      return {
        year:[],
        type:'0',
        fileList: [],
        queryParam:{
          type:'0',
          systemName:'',
          office:'',
          years:''
        },
          description: '',
        // 表头
        columns: [
          {
            title: '序号',
            align: "center",
            dataIndex: '',
            key: 'rowIndex',
            width: 60,
            customRender: function (t, r, index) {
              return parseInt(index) + 1;
            }
          },
          {
            title:'区县',
            align:"center",
            dataIndex: 'sysOrgCodeName',

          },
          {
            title:'创建时间',
            align:"center",
            // width: '10%',
            dataIndex: 'createTime',
          },
          {
            title: '年度',
            align: "center",
            // width: '10%',
            dataIndex: 'years',
          },
          {
            title: '报告类型',
            align: "center",
            // width: '10%',
            dataIndex: 'type_dictText',
          },
          {
            title:'报告时间',
            align:"center",
            dataIndex: 'date',
          },
          {
            title:'报告',
            align:"center",
            dataIndex: 'filePath',
          },
          {
            title: '操作',
            dataIndex: 'action',
            align:"center",
            scopedSlots: { customRender: 'action' },
          }
        ],
        columns1: [
          {
            title: '序号',
            align: "center",
            dataIndex: '',
            key: 'rowIndex',
            width: 60,
            customRender: function (t, r, index) {
              return parseInt(index) + 1;
            }
          },
          {
            title:'区县',
            align:"center",
            dataIndex: 'sysOrgCodeName',

          },
          {
            title:'创建时间',
            align:"center",
            width: '10%',
            dataIndex: 'createTime',
          },
          {
            title: '报告类型',
            align: "center",
            // width: '10%',
            dataIndex: 'type_dictText',
          },
          {
            title:'年度',
            align:"center",
            width: '10%',
            dataIndex: 'years',
          },
          {
            title:'月份',
            align:"center",
            width: '10%',
            dataIndex: 'date',
          },
          {
            title:'月度运行报告',
            align:"center",
            width: '20%',
            dataIndex: 'filePath',
          },

          {
            title: '操作',
            dataIndex: 'action',
            align:"center",
            scopedSlots: { customRender: 'action' },
          }
        ],
        columns2: [
          {
            title: '序号',
            align: "center",
            dataIndex: '',
            key: 'rowIndex',
            width: 60,
            customRender: function (t, r, index) {
              return parseInt(index) + 1;
            }
          },
          {
            title:'区县',
            align:"center",
            dataIndex: 'sysOrgCodeName',

          },
          {
            title:'创建时间',
            align:"center",
            width: '10%',
            dataIndex: 'createTime',
          },
          {
            title: '报告类型',
            align: "center",
            // width: '10%',
            dataIndex: 'type_dictText',
          },
          {
            title:'年度',
            align:"center",
            width: '10%',
            dataIndex: 'years',
          },
          {
            title:'季度',
            align:"center",
            width: '10%',
            dataIndex: 'date',
          },
          {
            title:'季度运行报告',
            align:"center",
            width: '10%',
            dataIndex: 'filePath',
          },
          {
            title: '操作',
            dataIndex: 'action',
            align:"center",
            scopedSlots: { customRender: 'action' },
          }
        ],
        columns3: [
          {
            title: '序号',
            align: "center",
            dataIndex: '',
            key: 'rowIndex',
            width: 60,
            customRender: function (t, r, index) {
              return parseInt(index) + 1;
            }
          },
          {
            title:'区县',
            align:"center",
            dataIndex: 'sysOrgCodeName',

          },
          {
            title:'创建时间',
            align:"center",
            width: '10%',
            dataIndex: 'createTime',
          },
          {
            title: '报告类型',
            align: "center",
            // width: '10%',
            dataIndex: 'type_dictText',
          },
          {
            title:'年度',
            align:"center",
            width: '10%',
            dataIndex: 'years',
          },
          {
            title:'年度运行报告',
            align:"center",
            width: '10%',
            dataIndex: 'filePath',
          },
          {
            title: '操作',
            dataIndex: 'action',
            align:"center",
            scopedSlots: { customRender: 'action' },
          }
        ],
        url: {
            list: "/jinanCloud/reportManage/list",
          uploadAction:window._CONFIG['domianURL']+"/sys/common/upload",
          urlDownload:window._CONFIG['domianURL'] + "/sys/common/download/",
          // exportXlsUrl: "/jinanAudit/auditMain/exportXls",
        },
        dictOptions:{
         office:[],
         tos:[],
        } 
      }
    },
    mounted() {
      this.init();
    },
    methods: {
      init(){
        this.getYear();
      },
      dateChange(obj){
        console.log(obj);
      },
      getYear(){//获取年
        let date = new Date();
        let current_year = date.getFullYear();
        // this.queryParam.yearDate=current_year;
        this.year=[];
        for (let i = 0; i < 30; i++) {
          let y = current_year - i;
          this.year.push({value:(y),label:(y)+ "年"});
          // this.yearDate.push(y);
          if(y=='1970'){
            return
          }
        }
      },
      searchQuery() {
        debugger
        let type=this.queryParam.type;
        this.type=type;
        this.loadData(1);
      },
      handleAdd: function (record) {
        this.$refs.modalForm.add(record);
        this.$refs.modalForm.title = "上传报告";
        this.$refs.modalForm.disableSubmit = false;
      },
    }
  }

</script>
<style scoped>
  @import '~@assets/less/common.less'
</style>